home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FSTAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  566 b   |  23 lines

  1. /* fstat.c, from page 358 of Turbo C Bible */
  2. #include <stdio.h>
  3. #include <sys\types.h>
  4. #include <sys\stat.h>
  5. #include <io.h>
  6. main ()
  7. {
  8.    struct stat info;
  9.    if (fstat (fileno (stdout), &info) != 0)
  10.    {
  11.         perror ("fstst failed");
  12.         exit (1);
  13.    }
  14.    if ((info.st_mode & S_IFCHR) == S_IFCHR)
  15.    {
  16.         printf ("stdout is a device\n");
  17.    }
  18.    if ((info.st_mode & S_IFREG) == S_IFREG)
  19.    {
  20.                /* This means stdout has been redirected to a file */
  21.     printf ("stdout is a regular file on drive %c\n", info.st_dev+65);
  22.    }
  23. }